package com.bidevalution.business.job;

import com.bidevalution.business.factory.StepJobJdbcFactory;
import com.bidevalution.business.service.JdbcTemplateService;
import com.bidevalution.dao.entity.BeSectionStepJob;
import org.apache.log4j.Logger;

import java.util.HashMap;
import java.util.Map;

public class DarkMarkComparisonJob implements StepJobJdbcFactory {
    private static Logger log = Logger.getLogger(SubmitNullControlJob.class);
    private JdbcTemplateService jdbcTemplateService;

    @Override
    public Boolean execute(BeSectionStepJob beSectionStepJob, String submitCode, String expertId, String layoutCode) throws Exception {
        try {
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("sectionId", beSectionStepJob.getSectionId());
            log.info("暗标对比表放开:"+layoutCode);
            StringBuilder sql = new StringBuilder();
            sql.append("UPDATE be_section_report SET report_expert=0 ")
                    .append(" WHERE section_id=:sectionId AND report_expert=-1");
            log.info("暗标对比表放开sql:"+sql.toString());
            jdbcTemplateService.update(sql.toString(), paramMap);
        } catch (Exception e) {
            log.error("暗标对比表放开错误：" + e.getMessage(), e);
            throw e;
        }
        return true;
    }

    @Override
    public void setJdbcTemplateService(JdbcTemplateService jdbcTemplateService) {
        this.jdbcTemplateService = jdbcTemplateService;
    }
}

